//
//  UIViewController+ProgressHUD.m
//  haierapp
//
//  Created by gaotangzhang on 14-8-29.
//  Copyright (c) 2014年 haier. All rights reserved.
//

#import "UIViewController+ProgressHUD.h"

#define AFTER_DELAY 2.0f

@implementation UIViewController (ProgressHUD)

//显示加载提示
-(void)showLoadingHud:(NSString *)text{
    //隐藏该View的其他HUD
    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
    
    MBProgressHUD *HUD=[MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    HUD.labelText=text;
}

//隐藏加载提示
-(void)hideLoadingHud{
    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}

//显示错误提示
-(void)showFailureHUD:(NSString *)text{
    
    //隐藏该View的其他HUD
    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
    
    MBProgressHUD *HUD=[MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    HUD.mode=MBProgressHUDModeCustomView;
    
    HUD.customView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@""]];
    
    HUD.labelText=text;
    
    [HUD show:YES];
    [HUD hide:YES afterDelay:2];
}

//显示成功提示
-(void)showSuccessHud:(NSString *)text{
    
    //隐藏该View的其他HUD
    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
    
    MBProgressHUD *HUD=[MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    HUD.mode=MBProgressHUDModeCustomView;
    
    HUD.customView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ico_right"]];
    
    HUD.labelText=text;
    
    [HUD show:YES];
    [HUD hide:YES afterDelay:2];
}

//显示文字提示
-(void)showTextHUD:(NSString *)text{
    
    //隐藏该View的其他HUD
    [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
    
    MBProgressHUD *HUD=[MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    HUD.mode=MBProgressHUDModeText;
    HUD.labelText=text;
    
    [HUD show:YES];
    [HUD hide:YES afterDelay:AFTER_DELAY];
}

//在window上显示提示
-(void)showSuccessHudInWindow:(NSString *)text{
    [MBProgressHUD hideAllHUDsForView:kAppWindow animated:YES];
    
    MBProgressHUD *HUD=[MBProgressHUD showHUDAddedTo:kAppWindow animated:YES];
    HUD.mode=MBProgressHUDModeCustomView;
    HUD.customView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ico_right"]];
    
    HUD.labelText=text;
    
    [HUD show:YES];
    [HUD hide:YES afterDelay:AFTER_DELAY];
    
}

//在window上显示文字提示
-(void)showTextHUDInWindow:(NSString *)text{
    [MBProgressHUD hideAllHUDsForView:kAppWindow animated:YES];
    
    MBProgressHUD *HUD=[MBProgressHUD showHUDAddedTo:kAppWindow animated:YES];
    
    HUD.mode=MBProgressHUDModeText;
    HUD.labelText=text;
    
    [HUD show:YES];
    [HUD hide:YES afterDelay:AFTER_DELAY];
}

@end
